<?php $this->widget('application.extensions.infieldlabel.InFieldLabel'); ?>
<div class="form">
<br/><br/>
  <h2 class="gline" style="width: 170px;">רישום פעילות חוגים</h2>
  <h5>לתאריך <?php echo date('d/m/Y',time()); ?></h5>
<br/>
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'activities-form',
	'enableAjaxValidation'=>true,
        'htmlOptions' => array('OnSubmit'=>'return CheckForm();'),
        
)); ?>
<fieldset>
<div class="bline">
        

        <div class="row" id="type_name">
                <?php echo $form->label($model,'type'); ?>
                <?php  $this->widget('CAutoComplete',
                      array(
                            'name'=>'activities[type]',
                            'url'=>array('/activities/findActivity'),
                            'max'=>10,
                            'minChars'=>1,
                            'delay'=>500,
                            'matchCase'=>false,
                            'methodChain'=>".result(function(event,item){\$(\"#activities_type_id\").val(item[1]);});",
                         ));
               ?>
                <?php echo $form->error($model,'type'); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'pupil_count'); ?>
		<?php echo $form->textField($model,'pupil_count'); ?>
		<?php echo $form->error($model,'pupil_count'); ?>
	</div>

	<div class="row">

            <div><strong>הערות</strong></div>
                <?php $this->widget('application.extensions.nicedit.NicEdit',
                    array('id' => 'activities_notes',
                          'options'=>array(
                                'name' => 'activities[notes]',
                                'rows'=>7,
                                'width'=>'400px',
                            ),
                        ));
                ?>
		<?php echo $form->error($model,'notes'); ?>
	</div>
</div>
        <?php echo CHtml::hiddenField('activities[type_id]'); ?>
        <?php echo CHtml::hiddenField('AnotherActivity'); ?>
        <?php echo $form->hiddenField($model,'user_id',array('value'=>Yii::app()->user->id));?>
        <?php echo $form->errorSummary($model); ?>
</fieldset>
	<br/><br/><br/><div class="row buttons">
                <?php echo CHtml::submitButton("שמור והוסף חוג נוסף", array('onclick'=>'javascript:$("#AnotherActivity").val(1);')) ?>
                <?php echo CHtml::submitButton("שמור וסיים", array('onclick'=>'javascript:$("#AnotherActivity").val(0);')) ?>
                
        </div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script language="javascript">
$(document).ready(function() {
    $(":input:visible:enabled:first").focus();
});


function CheckForm(){
  if($("#type_name").hasClass('error')){
        $("#activities_type_id").val('');
        return false;
    }
    return true;
}
</script>